#!/bin/sh
#
# Webif post-install script.
#
if [ "`grep "IW" "${IPKG_INSTROOT}/www/cgi-bin/webif/.categories"`" = "" ]; then
  echo "##WEBIF:category:IW" >> ${IPKG_INSTROOT}/www/cgi-bin/webif/.categories
fi
echo "
#### Chilli firewall configuration 
CHILLI="tun0"
iptables -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT

iptables -N CHILLI_ACCEPT
[ -z "\$WAN" ] || iptables -A CHILLI_ACCEPT -i "\$WAN" -j RETURN
[ -z "\$WANDEV" -o "\$WANDEV" = "\$WAN" ] || iptables -A CHILLI_ACCEPT -i "\$WANDEV" -j RETURN
iptables -A CHILLI_ACCEPT -j ACCEPT

iptables -A INPUT -j CHILLI_ACCEPT	# allow from wifi interfaces 

iptables -A FORWARD -i \$CHILLI -o \$CHILLI -j ACCEPT
[ -z "\$WAN" ] || iptables -A FORWARD -i \$CHILLI -o \$WAN -j ACCEPT
#### Chilli end
" >> "${IPKG_INSTROOT}/etc/firewall.user"